
<%@page import="edu.fiu.accesslog.statistics.LogStatistics"%>
<%@page import="edu.fiu.accesslog.statistics.Info"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<!DOCTYPE HTML>
<html>

<head>
  <title>Web-Log Analyzer</title>
  
  <meta name="description" content="website description" />
  <meta name="keywords" content="website keywords, website keywords" />
  <meta http-equiv="content-type" content="text/html; charset=windows-1252" />
  <link rel="stylesheet" type="text/css" href="style/style.css" />

  <script type="text/javascript" src="https://www.google.com/jsapi"></script>
                <script type="text/javascript">
                        google.load("visualization", "1", {packages:["corechart",'geochart']});
                        google.setOnLoadCallback(drawChart);
                  
                        function drawChart()
                        {
                        <%                              Info temp;%>
                                        //countryActivityChart();
                                        //foreignCountryActivityChart();
                                      hourlyActivityChart();
                                       // dailyActivityChart() ; 

                                }
                  
                                function countryActivityChart()
                                {
                                        var data  = new google.visualization.DataTable();
                                        var uniqueActData  = new google.visualization.DataTable();
                                        
                                        data.addColumn('string','Country');
                                        data.addColumn('number','Total Hit');
                                        
                                        uniqueActData.addColumn('string','Country');
                                        uniqueActData.addColumn('number','Total Hit');
                        <%
                                ArrayList<Info> cARList = LogStatistics.getInstance().getCountryActivityRecord();
                                //ArrayList<Info> aList = LogStatistics.getInstance().getForeignCountryActivityRecord();


                                for (int i = 0; i < cARList.size(); i++)
                                {
                                        temp = (Info) cARList.get(i);
                        %>
                                        data.addRow(["<%=temp.keyName%>",<%=temp.totalHit%>]);
                                        uniqueActData.addRow(["<%=temp.keyName%>",<%=temp.uniqueHit%>]);
                                        
                        <%
                                }
                                cARList = null;
                        %>                                            
                                        uniqueActData.sort([ {column: 1 , desc:true }]);
                                        data.sort([ {column: 1 , desc:true }]);
                              
                                        var options = 
                                                {
                                                title: 'Total Page Visits From Countries',
                                                is3D: true
                                        };
      
                                        var chart = new google.visualization.PieChart(document.getElementById('country_act'));
                                        var uniqueActChart = new google.visualization.PieChart(document.getElementById('country_unique_act'));
                                        
                                        
                                        chart.draw(data, options);
                                        uniqueActChart.draw(uniqueActData, {  title: 'Unique Page Visits From Countries', is3D: true });
                                }                  
                        
  
                                function foreignCountryActivityChart()
                                {
                                        var data  = new google.visualization.DataTable();
                                        data.addColumn('string','Country');
                                        data.addColumn('number','Total Hit');
                        <%
                                //ArrayList<Info> aList = LogStatistics.getInstance().getCountryActivityRecord();
                                ArrayList<Info> fCARList = LogStatistics.getInstance().getForeignCountryActivityRecord();


                                for (int i = 0; i < fCARList.size(); i++)
                                {
                                        temp = (Info) fCARList.get(i);
                        %>
                                        data.addRow(["<%=temp.keyName%>",<%=temp.totalHit%>]);
                        <%
                                }
                                fCARList = null;
                        %>                                            

      
                              
                                        var options = 
                                                {
                                                datalessRegionColor: 'white',
                                                colorAxis: {minValue: 0,  colors: ['#FFFFFF', '#0000FF']}
                                        };
      
                                        var chart = new google.visualization.GeoChart(document.getElementById('fr_country_act'));
                                        chart.draw(data, options);
                                }
                        
                                                
                        
                                function hourlyActivityChart() 
                                {
                                      var uniqueActData  = new google.visualization.DataTable();
                                       var data  = new google.visualization.DataTable();
                                        

                                        data.addColumn('string','Hour');
                                        data.addColumn('number','Total Hit');
                                         uniqueActData.addColumn('string','Hour');
                                        uniqueActData.addColumn('number','Unique Hit');                               
                        <%
                                //ArrayList<Info> aList = LogStatistics.getInstance().getCountryActivityRecord();
                                ArrayList<Info> hARList = LogStatistics.getInstance().getHourlyActivityRecord();


                                for (int i = 0; i < hARList.size(); i++)
                                {
                                        temp = (Info) hARList.get(i);
                        %>
                                        data.addRow(["<%=temp.keyName%>",<%=temp.totalHit%>]);
                                        uniqueActData.addRow(["<%=temp.keyName%>",<%=temp.uniqueHit%>]);
                        <%
                                }
                                hARList = null;
                        %>                                            
                  
                                        var options = {
                                                title: 'Number of Page Visits by Hour',
                                                colors:['red']
                                        };

                                        var chart = new google.visualization.AreaChart(document.getElementById('hourly_act'));
                                        var uniqueActChart = new google.visualization.AreaChart(document.getElementById('hourly_unique_act'));
                                        
                                        
                                        chart.draw(data, options);
                                        uniqueActChart.draw(uniqueActData, {  title: 'Unique Page Visits by Hour',colors:['#405000']});
                                  
                                }






                                function dailyActivityChart() 
                                {
                                        var data  = new google.visualization.DataTable();
                                        var uniqueActData  = new google.visualization.DataTable();
                                        data.addColumn('string','WeekDays');
                                        data.addColumn('number','Total Hit');
                                        
                                         uniqueActData.addColumn('string','WeekDays');
                                        uniqueActData.addColumn('number','Total Hit');
                        <%
                                //ArrayList<Info> aList = LogStatistics.getInstance().getCountryActivityRecord();
                                ArrayList<Info> dARList = LogStatistics.getInstance().getDailyActivityRecord();


                                for (int i = 0; i < dARList.size(); i++)
                                {
                                        temp = (Info) dARList.get(i);
                        %>
                                        data.addRow(["<%=temp.keyName%>",<%=temp.totalHit%>]);
                                        uniqueActData.addRow(["<%=temp.keyName%>",<%=temp.uniqueHit%>]);
                        <%
                                }
                                dARList = null;
                        %>                                            
                  
                                        var options =
                                        {
                                                title: 'Total Page Visits by Week Days'
                                        };

                                        var chart = new google.visualization.ColumnChart(document.getElementById('daily_act'));
                                        var uniqueActChart = new google.visualization.ColumnChart(document.getElementById('daily_unique_act'));
                                        
                                        chart.draw(data, options);
                                        uniqueActChart.draw(uniqueActData, {  title: 'Unique Page Visits by Week Days',colors:['#9900CC']});
                                }

                
                
                
                </script>
                
</head>

<body>
  <div id="main">
    <div id="header">
      <div id="logo">
        <div id="logo_text">
          <!-- class="logo_colour", allows you to change the colour of the text -->
          <h1><a href="index.html">Web-Log<span class="logo_colour">Analyzer</span></a></h1>
          <h2>Simple. Upload. Analyze.</h2>
        </div>
      </div>
      <div id="menubar">
        <ul id="menu">
          <!-- put class="selected" in the li tag for the selected page - to highlight which page you're on -->
          <li><a href="index.jsp">Home</a></li>
          <li><a href="country.jsp">Hits by Country</a></li>
          <li><a href="Outside.jsp">Hits from Outside</a></li>
          <li class="selected"><a href="Statistics.jsp">Daily Statistics</a></li>
          <li><a href="Week.jsp">Hits per Week</a></li>
        </ul>
      </div>
    </div>
    <div id="content_header"></div>
    <div id="site_content">
      <div class="sidebar">
        <!-- insert your sidebar items here -->
        <h4>Unique Visitors</h4>
         <p><a href="#">Daily</a></p>
        <p><a href="#">Weekly</a></p>
        <p><a href="#">Monthly</a></p>
        <p><a href="#">Hourly</a></p>
        <p><a href="#">Day of Week</a></p>
        <h3>Search</h3>
        <form method="post" action="#" id="search_form">
          <p>
            <input class="search" type="text" name="search_field" value="Enter keywords....." />
            <input name="search" type="image" style="border: 0; margin: 0 0 -9px 5px;" src="style/search.png" alt="Search" title="Search" />
          </p>
        </form>
      </div>
       <div id="content">
        <!-- insert the page content here -->
          <style>
                        .verticalSpace {margin-bottom: 1cm; }
                </style>
                <%--  <p class="verticalSpace"></p>
                <table border="1"  width="100%">
                        <tr>
                                <td WIDTH="50%">                
                                        <div id="country_act" > </div>
                                        
                                </td>
                                <td WIDTH="50%">
                                        <div id="country_unique_act" > </div>
                                </td>
                        </tr>

                </table>
                <p class="verticalSpace"></p>
                <hr>
                <h1>Page Visits From Foreign Countries</h1>
                <div id="fr_country_act" ></div>
                <p class="verticalSpace"></p>
                <hr>
                <p class="verticalSpace"></p>
                
                --%>   <table border="1"  width="100%">
                        <tr>
                                <td WIDTH="50%">                
                                        <div id="hourly_act" > </div>
                                        
                                </td>
                                <td WIDTH="50%">
                                        <div id="hourly_unique_act" > </div>
                                </td>
                        </tr>

                </table>              
                <%--<p class="verticalSpace"></p>
    
                <hr>
                <p class="verticalSpace"></p>
                
                   <table border="1"  width="100%">
                        <tr>
                                <td WIDTH="50%">                
                                        <div id="daily_act" > </div>
                                        
                                </td>
                                <td WIDTH="50%">
                                        <div id="daily_unique_act" > </div>
                                </td>
                        </tr>

                </table>                    
                --%>
                <hr>                 
                
      </div>
    </div>
    <div id="content_footer"></div>
    <div id="footer">
      <p><a href="index.jsp">Home</a> | <a href="country.jsp">Hits by Country</a> | <a href="Outside.jsp">Hits from Outside</a> | <a href="Statistics,jsp">Daily Statistics</a> | <a href="Week.jsp">Hits per Week</a></p>
      <p align="center">Copyright &copy; Web-Log Analyzer</p> </div>
  </div>
</body>
</html>

